#include <iostream>
#include "Record.h"
#include "Schema.h"
#include "DBFile.h"

#include "File.h"

int main(){
	Schema schema("catalog","lineitem");
	Record record;
	DBFile dbfile;
	int i ;
	Page page;
	
	//dbfile.Create("./lineitem.db", heap, NULL);
	//dbfile.Load(schema, "./db/lineitem.tbl");
	//FILE * file = fopen ( "./db/lineitem.tbl", "r");
	
	//record.SuckNextRecord(&schema, file);
	
	//dbfile.Open("./lineitem.db");
	
	//while ( dbfile.GetNext(record) ){
		//record.Print(&schema);
	//}
	
	
	//dbfile.Add(record);
	
	//dbfile.Close();
	
	/*print last page*/
	File lineitem;
	lineitem.Open(1, "./lineitem.db");
	cout << "total pages in the table : "  << lineitem.GetLength() << endl;
	lineitem.GetPage(&page, 98);
	while ( page.GetFirst(&record) )
	{
		record.Print(&schema);
		
	}
	
	/*int countPage=0;
	for( i = 0 ; i < 101; i++ ){
			cout << "fetching page: " << countPage++ << endl;
			lineitem.GetPage(&page, i);
	}
	
	
	//page.EmptyItOut();
	
	//fclose(file);
	*/
	
	return 0;
}
